/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.anwarsumawang.salapi;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Anwar
 */
public abstract class Connector {

    public static Connection getConnection() {
        String jdbcConncetionString = "jdbc:mysql://localhost/salapi?user=root&password=";
        String jdbcDriver = "com.mysql.jdbc.Driver";
        Connection conn = null;
        try {
            Class.forName(jdbcDriver);

        } catch (ClassNotFoundException ex) {
            System.err.println("Error loading database driver " + jdbcDriver + ": \n" + ex.getMessage());
        }

        try {
            conn = DriverManager.getConnection(jdbcConncetionString);
        } catch (SQLException ex) {
            System.err.println("Error connecting to the database: \n" + ex.getMessage());
        }
        
        return conn;
    }
}
